package com.aghcampusnavigation.navi.model;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.aghcampusnavigation.navi.DataOfBuilding;
import com.aghcampusnavigation.navi.R;

/**
 * Created by Filip on 01.05.14.
 */
public class BuildingsArrayAdapter extends ArrayAdapter<DataOfBuilding> {
    private final Context context;
    private final DataOfBuilding[] values;

    public BuildingsArrayAdapter(Context context, DataOfBuilding[] values) {
        super(context, R.layout.buildingsrowlayout, values);
        this.context = context;
        this.values = values;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.buildingsrowlayout, parent, false);

        TextView name = (TextView) rowView.findViewById(R.id.buildingRowName);
        name.setText(values[position].gettingNumber());

        TextView desc = (TextView) rowView.findViewById(R.id.buildingRowDesc);
        desc.setText(values[position].gettingDescription());

        return rowView;
    }
}